package com.ngsky.ana.detail;

import javax.swing.*;
import java.awt.*;

/**
 * @Author syx
 * @Desc
 * @Create 2020/6/15 0:03
 */
public class ColorItem extends JPanel {
    public ColorItem(String colorName, Color colorVal, String ratVal){
        JLabel lab = new JLabel(colorName, 0);
        lab.setPreferredSize(new Dimension(90, 40));
        lab.setBackground(colorVal);
        lab.setOpaque(true);

        String colorRGB = "#" + Integer.toHexString(colorVal.getRed()) + Integer.toHexString(colorVal.getGreen()) + Integer.toHexString(colorVal.getBlue()) + Integer.toHexString(colorVal.getAlpha());
        JLabel rgb = new JLabel(colorRGB);
        rgb.setPreferredSize(new Dimension(60, 40));

        JLabel rat = new JLabel(ratVal);
        rat.setPreferredSize(new Dimension(60, 40));

        add(lab);
        add(rgb);
        add(rat);
    }
}
